(function () {
    var vm = new Vue({
        el: '#wrapper',
        data: {
            p_obj: { url: 'logo', text: '提示文字' },
            validateDisable: 'orderValidateDisable',
            validateCurrentUserDisable: '',
            registerDiable: true,
            familyTitle: "新增就诊人",
            pid: 0,
            currentUserMobile: '',
            userName: '',
            loginInfo: { isLogin: '', name: '', mobile: '' },
            bDoctorDateVisible: false,
            bDoctorTimeVisible: false,
            selectedDate: '',
            isGuset: true,
            showAdd: false,
            showmessage: false,
            bcityVisible: false,
            bOrganizationVisible: false,
            visitingPersonActive: 'visitingPersonReady_active',
            visitingPersonDisactive: '',
            addBtn: 'add-btn',
            reduceBtn: 'reduce-btn',
            sOrderTip: '',
            Id: "",
            Name: '',
            Image: '',
            TitleName: '',
            DeptName: '',
            DepName2: '',
            DeptID: '',
            OrgName: '',
            OrgId: '',
            AffiliatedHospital: '',
            SkillIn: '',
            ClinicID: '',
            ClinicinfoID: '',
            HospitalID: '',
            RegistrationFee: '',
            RemoteRegistrationFee: '',
            RegistrationFeeText: '',
            IsRemote: '',
            ValidateCode: '',
            isFamilyMemberAddDisable: 'familyMemberAddDisable',
            isUpdateFamilyMember: '',
            FamilyMemberNoAndValidationCodeKey:'',
            doctorInfo: {
                Id: -1,
                Name: '',
                Image: '',
                DeptName: '',
                DepName2: '',
                DeptID: '',
                TitleName: '',
                OrgId: '',
                OrgName: '',
                AffiliatedHospital: '',
                SkillIn: ''
            },
            doctorDates: [],
            selectedCityId: '',
            selectedCityName: '请选择城市',
            citylist: [],
            city: { id: '', name: '', bcityActive: false },
            selectedOrganizationId: '',
            selectedOrganizationName: '请选择看诊地点',
            selectedOrganizationAddress: '',
            selectedOrganizationRemoteHospId: '',
            selecteddoctorDate: '请选择日期',
            selecteddoctorTime: '请选择时间段',
            organizationList: [],
            familyMemberList: [],
            doctorTimeList: [],
            Organization: {
                hospitalID: '',
                hospitalName: '',
                hospitalAddress: '',
                hospitalImage: '',
                hospitalComment: '',
                coordinate: '',
                remote: '',
                type: '',
                iscentral: '',
                rating: [],
                borganizationActive: false
            },
            SelectedFamilyMemberId: -1,
            FamilyMember: {
                Age: null,
                Birthday: null,
                CreateTime: '',
                FamilyAddress: '',
                FamilyMobile: '',
                FamilyName: '',
                FamilyPID: '',
                Gender: '',
                IDCardNo: '',
                Id: -1,
                IsDefault: false,
                IsSelected: false,
                Pid: -1,
                Relationship: '',
                Remark: '',
                UpdateTime: '',
                ValidateCode: '',
                UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
            },
            UpdateFamilyMember: {
                Age: null,
                Birthday: null,
                CreateTime: '',
                FamilyAddress: '',
                FamilyMobile: '',
                FamilyName: '',
                FamilyPID: '',
                Gender: '',
                IDCardNo: '',
                Id: -1,
                IsDefault: false,
                IsSelected: false,
                Pid: -1,
                Relationship: '',
                Remark: '',
                UpdateTime: '',
                ValidateCode: '',
                UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
            },
            SubDate: { TimeTarget: '', Time: '', NoBooking: false },
            morningTimeList: [],
            morningTime: { TimeTarget: '', Time: '', bmorningA_click: true, bmorningA_noClickActive: false },
            afternoonTimeList: [],
            afternoonTime: { TimeTarget: '', Time: '', bafternoonA_click: true, bafternoonA_noClickActive: false },
            eveningTimeList: [],
            eveningTime: { TimeTarget: '', Time: '', beveningA_click: true, beveningA_noClickActive: false },
            images: [],
            saveimages: [],
            imageitem: { src: '' },
            description: '',
            userInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" },
            SelectedUserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" },
            morningspotshow: false,
            afternoonspotshow: false,
            eveningspotshow: false,
            orderSuccess: {
                show: false,
                doctorId: '',
                date: '2016年01月25日 09:00-12:00',
                expertName: '宋冬雷',
                hospital: '复旦大学附属华山医院',
                address: '上海静安区乌鲁木齐路12号',
                fee: '500'
            },
            inquiryDate: '请选择日期',
            allGoodText: false //擅长展开收起标识
        },
        components: {
            'clinic-head': clinicHead,
            'clinic-right': clinicRight,
            'clinic-foot': clinicFoot,
            'order-success-dialog': orderSuccessDialog
        },
        created: function () {
            var _self = this;
            //检查登录状态
            CheckLoginStatus(_self, _self.loginInfo);
        },
        methods: {
            getValidDate: function () {
                var _self = this;
                var doctorid = window.location.search.split('=')[1];
                _self.$http.post("/Order/GetDoctorScheduleBydocID",
                    { docID: doctorid }).then(
                    function (res) {
                        if (res.status == 200) {
                            for (var i = 0; i < res.body.length; i++) {
                                _self.doctorDates.push(res.body[i].split('-').reverse().join(' '));
                            }
                            _self.getDate();
                        }
                    });
            },
            getDate: function () {
                var _self = this;
                $('.selectDepartment').hide();
                $('.doctorTime_spotList').hide();
                $('.selectCity').hide();
                $('#dateWrap').show();

                $('#datePicker').Zebra_DatePicker({
                    always_visible: $('#dateWrap'),
                    format: 'Y-m-d w',
                    enabled_dates: _self.doctorDates,
                    //disabled_dates: ['* * * 0'],
                    //direction: 1, //往前可以选择
                    //direction: [1, 10],//未来10天内可选择
                    direction: [1, 180], //用日期表示取可选区间
                    disabled_dates: ['* * * *'], // 全部禁用
                    onChange: function (view, elements) {

                    },
                    onSelect: function (dateText, inst) {
                        var temp = dateText.split(' ');
                        var week = temp[1];
                        if (week == "0") {
                            week = " 星期日";
                        } else if (week == "1") {
                            week = " 星期一";
                        }
                        else if (week == "2") {
                            week = " 星期二";
                        }
                        else if (week == "3") {
                            week = " 星期三";
                        }
                        else if (week == "4") {
                            week = " 星期四";
                        }
                        else if (week == "5") {
                            week = " 星期五";
                        }
                        else if (week == "6") {
                            week = " 星期六";
                        }
                        dateText = temp[0] + week;
                        _self.inquiryDate = temp[0] + week;
                        //$('#datePicker').val(dateText);

                        _self.selecteddoctorTime = "请选择时间段";
                        _self.doctorTimeList = [];

                        _self.morningTimeList = [];
                        _self.afternoonTimeList = [];
                        _self.eveningTimeList = [];

                        _self.morningspotshow = false;
                        _self.afternoonspotshow = false;
                        _self.eveningspotshow = false;

                        $('#dateWrap').hide();
                    }
                });
            },
            hiddenDoctorDateDetail: function () { $('#dateWrap').hide(); },
            hiddenDoctorTimeDetail: function () { $('.doctorTime_spotList').hide(); },
            hiddenCityItem: function () { $('.selectCity').hide(); },
            hiddenOrganizationItem: function () { $('.selectDepartment').hide(); },
            InputFunc: function () {
                var _self = this;
                if (_self.FamilyMember.FamilyName != "" &&
                    _self.FamilyMember.FamilyMobile != "" &&
                    _self.FamilyMember.ValidateCode != "" &&
                    _self.FamilyMember.IDCardNo != "") {
                    _self.isFamilyMemberAddDisable = "";
                } else {
                    _self.isFamilyMemberAddDisable = "familyMemberAddDisable";
                }
            },
            registerValidation: function () {
                var _self = this,
                    tipBox = document.getElementById("tipBox");

                tipBox.style.display = "none";

                if (_self.FamilyMember.FamilyName != "" &&
                    _self.FamilyMember.FamilyMobile != "" &&
                    _self.FamilyMember.ValidateCode != "" &&
                    _self.FamilyMember.IDCardNo != "") {
                    _self.isFamilyMemberAddDisable = "";
                } else {
                    _self.isFamilyMemberAddDisable = "familyMemberAddDisable";
                }

                //if (_self.FamilyMember.FamilyMobile == "") {
                //    _self.validateDisable = "orderValidateDisable";
                //} else {
                //    _self.validateDisable = "";
                //}

            },
            FamilyMemberSetDefault: function ($event) {
                var _self = this;
                var setid = $event.currentTarget.id;
                var familyMemberListData = _self.familyMemberList;
                var familyMemberList = [];

                for (var i = 0; i < familyMemberListData.length; i++) {
                    var familyMember = {
                        Age: null,
                        Birthday: null,
                        CreateTime: '',
                        FamilyAddress: '',
                        FamilyMobile: '',
                        FamilyName: '',
                        FamilyPID: '',
                        Gender: '',
                        IDCardNo: '',
                        Id: -1,
                        IsDefault: false,
                        IsSelected: false,
                        Pid: -1,
                        Relationship: '',
                        Remark: '',
                        UpdateTime: '',
                        ValidateCode: '',
                        UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                    };

                    familyMember.Id = familyMemberListData[i].Id;
                    familyMember.Age = familyMemberListData[i].Age;
                    familyMember.Pid = familyMemberListData[i].Pid;
                    familyMember.FamilyPID = familyMemberListData[i].FamilyPID;
                    familyMember.Relationship = familyMemberListData[i].Relationship;
                    familyMember.Birthday = familyMemberListData[i].Birthday;
                    familyMember.IsDefault = familyMemberListData[i].IsDefault;
                    familyMember.IsSelected = familyMemberListData[i].Id.toString() === setid ? true : false;
                    familyMember.FamilyName = familyMemberListData[i].FamilyName;
                    familyMember.FamilyMobile = familyMemberListData[i].FamilyMobile;
                    familyMember.FamilyAddress = familyMemberListData[i].FamilyAddress;
                    familyMember.Gender = familyMemberListData[i].Gender;
                    familyMember.IDCardNo = familyMemberListData[i].IDCardNo;
                    familyMember.CreateTime = familyMemberListData[i].CreateTime;
                    familyMember.UpdateTime = familyMemberListData[i].UpdateTime;
                    familyMember.Remark = familyMemberListData[i].Remark;

                    familyMember.UserInfoJson.Pid = familyMemberListData[i].Pid;
                    familyMember.UserInfoJson.Name = familyMemberListData[i].FamilyName;
                    familyMember.UserInfoJson.Mobile = familyMemberListData[i].FamilyMobile;
                    familyMember.UserInfoJson.Sex = familyMemberListData[i].Gender;
                    familyMember.UserInfoJson.CertNo = familyMemberListData[i].IDCardNo;
                    familyMember.UserInfoJson.Birthday = familyMemberListData[i].Birthday;

                    if (familyMemberListData[i].Id.toString() === setid) {
                        _self.SelectedFamilyMemberId = familyMemberListData[i].Id;
                        _self.userInfoJson = familyMember.UserInfoJson;
                        _self.SelectedUserInfoJson = familyMember.UserInfoJson;
                    }

                    familyMemberList.push(familyMember);
                }
                _self.familyMemberList = familyMemberList;
            },
            FamilyMemberAdd: function () {
                var _self = this;
                _self.familyTitle = "新增就诊人";
                if (_self.isUpdateFamilyMember == "update") {
                    var tipBox = document.getElementById("tipBox");
                    tipBox.style.display = "none";

                    var idcardpatrn = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                    var idcardpatrns = /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$/;

                    if (!(/[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*/.test(_self.FamilyMember.FamilyName))) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的姓名";
                        return false;
                    }
                    else if (_self.FamilyMember.FamilyMobile == null || _self.FamilyMember.FamilyMobile == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输手机号";
                        return false;
                    }
                    else if (!(/^1[34578]\d{9}$/.test(_self.FamilyMember.FamilyMobile))) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确格式的手机号码";
                        return false;
                    }
                    else if (_self.FamilyMember.ValidateCode == null || _self.FamilyMember.ValidateCode == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入验证码";
                        return false;
                    }
                    else if (_self.FamilyMember.IDCardNo == null || _self.FamilyMember.IDCardNo == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入证件号码";
                        return false;
                    }
                    else if (!idcardpatrn.test(_self.FamilyMember.IDCardNo)) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的证件号码";
                        return false;

                    }
                    else if (_self.FamilyMember.FamilyMobile != _self.currentUserMobile && _self.FamilyMember.ValidateCode != _self.ValidateCode) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的验证码";
                        return false;
                    }

                    var familyMemberNoAndValidationCodeKeys = _self.FamilyMember.FamilyMobile + $(".validateCode").val();
                    if (_self.FamilyMemberNoAndValidationCodeKey !== familyMemberNoAndValidationCodeKeys) {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "就诊人手机号与验证码不匹配" });
                        return false;
                    }

                    _self.$http.post("/Order/FamilyMemberUpdate", _self.FamilyMember).then(function (res) {
                        if (res.body != -1) {
                            tipBox.style.display = "none";
                            _self.showAdd = false;

                            _self.familyMemberList = [];
                            this.$http.post("/Order/GetFamilyMemberList",
                                { pid: 0 }).then(function (res) {
                                for (var i = 0; i < res.body.length; i++) {
                                    _self.FamilyMember = {
                                        Age: null,
                                        Birthday: null,
                                        CreateTime: '',
                                        FamilyAddress: '',
                                        FamilyMobile: '',
                                        FamilyName: '',
                                        FamilyPID: '',
                                        Gender: '',
                                        IDCardNo: '',
                                        Id: -1,
                                        IsDefault: false,
                                        IsSelected: false,
                                        Pid: -1,
                                        Relationship: '',
                                        Remark: '',
                                        UpdateTime: '',
                                        ValidateCode: '',
                                        UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                                    };
                                    _self.FamilyMember.Id = res.body[i].Id;
                                    _self.FamilyMember.Age = res.body[i].Age;
                                    _self.FamilyMember.Pid = res.body[i].Pid;
                                    _self.FamilyMember.FamilyPID = res.body[i].FamilyPID;
                                    _self.FamilyMember.Relationship = res.body[i].Relationship;
                                    _self.FamilyMember.Birthday = res.body[i].Birthday;
                                    _self.FamilyMember.IsDefault = res.body[i].IsDefault;
                                    _self.FamilyMember.IsSelected = _self.SelectedFamilyMemberId === res.body[i].Id ? true : false;
                                    _self.FamilyMember.FamilyName = res.body[i].FamilyName;
                                    _self.FamilyMember.FamilyMobile = res.body[i].FamilyMobile;
                                    _self.FamilyMember.FamilyAddress = res.body[i].FamilyAddress;
                                    _self.FamilyMember.Gender = res.body[i].Gender;
                                    _self.FamilyMember.IDCardNo = res.body[i].IDCardNo;
                                    _self.FamilyMember.CreateTime = res.body[i].CreateTime;
                                    _self.FamilyMember.UpdateTime = res.body[i].UpdateTime;
                                    _self.FamilyMember.Remark = res.body[i].Remark;

                                    _self.FamilyMember.UserInfoJson.Pid = res.body[i].Pid;
                                    _self.FamilyMember.UserInfoJson.Name = res.body[i].FamilyName;
                                    _self.FamilyMember.UserInfoJson.Mobile = res.body[i].FamilyMobile;
                                    _self.FamilyMember.UserInfoJson.Sex = res.body[i].Gender;
                                    _self.FamilyMember.UserInfoJson.CertNo = res.body[i].IDCardNo;
                                    _self.FamilyMember.UserInfoJson.Birthday = res.body[i].Birthday;

                                    if (res.body[i].IsSelected) {
                                        _self.SelectedFamilyMemberId = res.body[i].Id;
                                        _self.userInfoJson = _self.FamilyMember.UserInfoJson;
                                    }

                                    _self.familyMemberList.push(_self.FamilyMember);
                                }
                                _self.FamilyMember = {
                                    Age: null,
                                    Birthday: null,
                                    CreateTime: '',
                                    FamilyAddress: '',
                                    FamilyMobile: '',
                                    FamilyName: '',
                                    FamilyPID: '',
                                    Gender: '',
                                    IDCardNo: '',
                                    Id: -1,
                                    IsDefault: false,
                                    IsSelected: false,
                                    Pid: -1,
                                    Relationship: '',
                                    Remark: '',
                                    UpdateTime: '',
                                    ValidateCode: '',
                                    UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                                };
                            });
                        }
                        else {
                            tipBox.style.display = "block";
                            _self.sOrderTip = res.body.Msg;
                            _self.showAdd = true;
                        }
                    });
                } else {

                    var tipBox = document.getElementById("tipBox");
                    tipBox.style.display = "none";

                    var idcardpatrn = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
                    var idcardpatrns = /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$/;

                    if (!(/[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*/.test(_self.FamilyMember.FamilyName))) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的姓名";
                        return false;
                    }
                    else if (_self.FamilyMember.FamilyMobile == null || _self.FamilyMember.FamilyMobile == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输手机号";
                        return false;
                    }
                    else if (!(/^1[34578]\d{9}$/.test(_self.FamilyMember.FamilyMobile))) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确格式的手机号码";
                        return false;
                    }
                    else if (_self.FamilyMember.ValidateCode == null || _self.FamilyMember.ValidateCode == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入验证码";
                        return false;
                    }
                    else if (_self.FamilyMember.IDCardNo == null || _self.FamilyMember.IDCardNo == "") {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入证件号码";
                        return false;
                    }
                    else if (!idcardpatrn.test(_self.FamilyMember.IDCardNo)) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的证件号码";
                        return false;

                    }
                    else if (_self.FamilyMember.FamilyMobile != _self.currentUserMobile && _self.FamilyMember.ValidateCode != _self.ValidateCode) {
                        tipBox.style.display = "block";
                        _self.sOrderTip = "请输入正确的验证码";
                        return false;
                    }

                    var familyMemberNoAndValidationCodeKey = _self.FamilyMember.FamilyMobile + $(".validateCode").val();
                    if (_self.FamilyMemberNoAndValidationCodeKey != familyMemberNoAndValidationCodeKey) {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "就诊人手机号与验证码不匹配" });
                        return false;
                    }

                    _self.$http.post("/Order/FamilyMemberAdd", _self.FamilyMember).then(function (res) {
                        if (res.body != -1) {
                            tipBox.style.display = "none";
                            _self.showAdd = false;

                            _self.familyMemberList = [];
                            this.$http.post("/Order/GetFamilyMemberList",
                                { pid: 0 }).then(function (res) {
                                for (var i = 0; i < res.body.length; i++) {
                                    _self.FamilyMember = {
                                        Age: null,
                                        Birthday: null,
                                        CreateTime: '',
                                        FamilyAddress: '',
                                        FamilyMobile: '',
                                        FamilyName: '',
                                        FamilyPID: '',
                                        Gender: '',
                                        IDCardNo: '',
                                        Id: -1,
                                        IsDefault: false,
                                        IsSelected: false,
                                        Pid: -1,
                                        Relationship: '',
                                        Remark: '',
                                        UpdateTime: '',
                                        ValidateCode: '',
                                        UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                                    };
                                    _self.FamilyMember.Id = res.body[i].Id;
                                    _self.FamilyMember.Age = res.body[i].Age;
                                    _self.FamilyMember.Pid = res.body[i].Pid;
                                    _self.FamilyMember.FamilyPID = res.body[i].FamilyPID;
                                    _self.FamilyMember.Relationship = res.body[i].Relationship;
                                    _self.FamilyMember.Birthday = res.body[i].Birthday;
                                    _self.FamilyMember.IsDefault = res.body[i].IsDefault;
                                    _self.FamilyMember.IsSelected = _self.SelectedFamilyMemberId === res.body[i].Id ? true : false;
                                    _self.FamilyMember.FamilyName = res.body[i].FamilyName;
                                    _self.FamilyMember.FamilyMobile = res.body[i].FamilyMobile;
                                    _self.FamilyMember.FamilyAddress = res.body[i].FamilyAddress;
                                    _self.FamilyMember.Gender = res.body[i].Gender;
                                    _self.FamilyMember.IDCardNo = res.body[i].IDCardNo;
                                    _self.FamilyMember.CreateTime = res.body[i].CreateTime;
                                    _self.FamilyMember.UpdateTime = res.body[i].UpdateTime;
                                    _self.FamilyMember.Remark = res.body[i].Remark;

                                    _self.FamilyMember.UserInfoJson.Pid = res.body[i].Pid;
                                    _self.FamilyMember.UserInfoJson.Name = res.body[i].FamilyName;
                                    _self.FamilyMember.UserInfoJson.Mobile = res.body[i].FamilyMobile;
                                    _self.FamilyMember.UserInfoJson.Sex = res.body[i].Gender;
                                    _self.FamilyMember.UserInfoJson.CertNo = res.body[i].IDCardNo;
                                    _self.FamilyMember.UserInfoJson.Birthday = res.body[i].Birthday;

                                    if (res.body[i].IsSelected) {
                                        _self.SelectedFamilyMemberId = res.body[i].Id;
                                        _self.userInfoJson = _self.FamilyMember.UserInfoJson;
                                    }

                                    _self.familyMemberList.push(_self.FamilyMember);
                                }
                                _self.FamilyMember = {
                                    Age: null,
                                    Birthday: null,
                                    CreateTime: '',
                                    FamilyAddress: '',
                                    FamilyMobile: '',
                                    FamilyName: '',
                                    FamilyPID: '',
                                    Gender: '',
                                    IDCardNo: '',
                                    Id: -1,
                                    IsDefault: false,
                                    IsSelected: false,
                                    Pid: -1,
                                    Relationship: '',
                                    Remark: '',
                                    UpdateTime: '',
                                    ValidateCode: '',
                                    UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                                };
                            });
                        }
                        else {
                            tipBox.style.display = "block";
                            _self.sOrderTip = res.body.Msg;
                            _self.showAdd = true;
                        }
                    });
                }
            },
            FamilyMemberUpdate: function ($event) {
                var _self = this;
                var tipBox = document.getElementById("tipBox");
                tipBox.style.display = "none";

                if (!(/[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*/.test(_self.UpdateFamilyMember.FamilyName))) {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入正确的姓名";
                    return false;
                }
                else if (_self.UpdateFamilyMember.FamilyMobile == null || _self.UpdateFamilyMember.FamilyMobile == "") {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输手机号";
                    return false;
                }
                else if (!(/^1[34578]\d{9}$/.test(_self.UpdateFamilyMember.FamilyMobile))) {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入正确格式的手机号码";
                    return false;
                }
                else if (_self.UpdateFamilyMember.ValidateCode == null || _self.UpdateFamilyMember.ValidateCode == "") {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入验证码";
                    return false;
                }
                else if (!(/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(_self.UpdateFamilyMember.IDCardNo))) {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入正确的证件号码";
                    return false;
                }
                else if (_self.FamilyMember.FamilyMobile != _self.currentUserMobile && _self.UpdateFamilyMember.ValidateCode != _self.ValidateCode) {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入正确的验证码";
                    return false;
                }

                _self.$http.post("/Order/FamilyMemberUpdate", _self.UpdateFamilyMember).then(function (res) {
                    if (res.body.Id != -1) {
                        tipBox.style.display = "none";
                        _self.showAdd = false;

                        _self.familyMemberList = [];
                        this.$http.post("/Order/GetFamilyMemberList",
                            { pid: 0 }).then(function (res) {
                            for (var i = 0; i < res.body.length; i++) {
                                _self.UpdateFamilyMember = {
                                    Age: null,
                                    Birthday: null,
                                    CreateTime: '',
                                    FamilyAddress: '',
                                    FamilyMobile: '',
                                    FamilyName: '',
                                    FamilyPID: '',
                                    Gender: '',
                                    IDCardNo: '',
                                    Id: -1,
                                    IsDefault: false,
                                    IsSelected: false,
                                    Pid: -1,
                                    Relationship: '',
                                    Remark: '',
                                    UpdateTime: '',
                                    ValidateCode: '',
                                    UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                                };
                                _self.FamilyMember.Id = res.body[i].Id;
                                _self.FamilyMember.Age = res.body[i].Age;
                                _self.FamilyMember.Pid = res.body[i].Pid;
                                _self.FamilyMember.FamilyPID = res.body[i].FamilyPID;
                                _self.FamilyMember.Relationship = res.body[i].Relationship;
                                _self.FamilyMember.Birthday = res.body[i].Birthday;
                                _self.FamilyMember.IsDefault = res.body[i].IsDefault;
                                _self.FamilyMember.IsSelected = _self.SelectedFamilyMemberId === res.body[i].Id ? true : false;
                                _self.FamilyMember.FamilyName = res.body[i].FamilyName;
                                _self.FamilyMember.FamilyMobile = res.body[i].FamilyMobile;
                                _self.FamilyMember.FamilyAddress = res.body[i].FamilyAddress;
                                _self.FamilyMember.Gender = res.body[i].Gender;
                                _self.FamilyMember.IDCardNo = res.body[i].IDCardNo;
                                _self.FamilyMember.CreateTime = res.body[i].CreateTime;
                                _self.FamilyMember.UpdateTime = res.body[i].UpdateTime;
                                _self.FamilyMember.Remark = res.body[i].Remark;

                                _self.FamilyMember.UserInfoJson.Pid = res.body[i].Pid;
                                _self.FamilyMember.UserInfoJson.Name = res.body[i].FamilyName;
                                _self.FamilyMember.UserInfoJson.Mobile = res.body[i].FamilyMobile;
                                _self.FamilyMember.UserInfoJson.Sex = res.body[i].Gender;
                                _self.FamilyMember.UserInfoJson.CertNo = res.body[i].IDCardNo;
                                _self.FamilyMember.UserInfoJson.Birthday = res.body[i].Birthday;

                                if (res.body[i].IsSelected) {
                                    _self.SelectedFamilyMemberId = res.body[i].Id;
                                    _self.userInfoJson = _self.FamilyMember.UserInfoJson;
                                }

                                _self.familyMemberList.push(_self.FamilyMember);
                            }
                            _self.UpdateFamilyMember = {
                                Age: null,
                                Birthday: null,
                                CreateTime: '',
                                FamilyAddress: '',
                                FamilyMobile: '',
                                FamilyName: '',
                                FamilyPID: '',
                                Gender: '',
                                IDCardNo: '',
                                Id: -1,
                                IsDefault: false,
                                IsSelected: false,
                                Pid: -1,
                                Relationship: '',
                                Remark: '',
                                UpdateTime: '',
                                ValidateCode: '',
                                UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                            };
                        });
                    }
                    else {
                        tipBox.style.display = "block";
                        _self.sOrderTip = res.body.Msg;
                        _self.showAdd = true;
                    }
                });
            },
            PhoneValidate: function () {
                var _self = this;
                _self.validateDisable = '';
                if (_self.FamilyMember.FamilyMobile == "") {
                    _self.validateDisable = "orderValidateDisable";
                }

                if (_self.FamilyMember.FamilyName != "" &&
                    _self.FamilyMember.FamilyMobile != "" &&
                    _self.FamilyMember.ValidateCode != "" &&
                    _self.FamilyMember.IDCardNo != "") {
                    _self.isFamilyMemberAddDisable = "";
                } else {
                    _self.isFamilyMemberAddDisable = "familyMemberAddDisable";
                }
            },
            //获取验证码
            getValidateCode: function () {
                var _self = this;
                var tipBox = document.getElementById("tipBox");

                if (_self.FamilyMember.FamilyMobile == null || _self.FamilyMember.FamilyMobile == "") {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输手机号";
                    return false;
                }
                else if (!(/^1[34578]\d{9}$/.test(_self.FamilyMember.FamilyMobile))) {
                    tipBox.style.display = "block";
                    _self.sOrderTip = "请输入正确格式的手机号码";
                    return false;
                }

                tipBox.style.display = "none";
                _self.$http.post("/Order/GetValidateCode", _self.FamilyMember).then(function (res) {
                    if (res.body.Code === -1) {
                        _self.p_obj.url = "/styles/image/icon/no.png";
                    }
                    else {
                        _self.p_obj.url = "/styles/image/icon/ok.png";
                        _self.ValidateCode = res.body.Code;

                        _self.FamilyMemberNoAndValidationCodeKey = _self.FamilyMember.FamilyMobile + _self.ValidateCode;
                    }

                    _self.p_obj.text = res.body.Msg;
                    dialogTip(_self.p_obj);
                    if (res.body.Code != -1) {
                        sendCode(document.getElementById("getValidateCode"));
                        _self.validateDisable = "orderValidateDisable";
                    } else {
                        _self.validateDisable = "";
                    }
                });
            },
            clickAdd: function () {
                var _self = this;
                _self.showAdd = !_self.showAdd;
                _self.isUpdateFamilyMember = "";
                _self.familyTitle = "新增就诊人";
            },
            clickUpdate: function ($event) {
                var _self = this;
                _self.familyTitle = "修改就诊人";
                _self.isUpdateFamilyMember = "update";
                _self.showAdd = true;
                var updateid = $event.currentTarget.id;
                var familyMemberLists = _self.familyMemberList;
                _self.FamilyMember = {
                    Age: null,
                    Birthday: null,
                    CreateTime: '',
                    FamilyAddress: '',
                    FamilyMobile: '',
                    FamilyName: '',
                    FamilyPID: '',
                    Gender: '',
                    IDCardNo: '',
                    Id: -1,
                    IsDefault: false,
                    IsSelected: false,
                    Pid: -1,
                    Relationship: '',
                    Remark: '',
                    UpdateTime: '',
                    ValidateCode: '',
                    UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                };
                for (var i = 0; i < familyMemberLists.length; i++) {
                    if (familyMemberLists[i].Id == updateid) {
                        _self.FamilyMember.Id = familyMemberLists[i].Id;
                        _self.FamilyMember.Pid = familyMemberLists[i].Pid;
                        _self.FamilyMember.FamilyPID = familyMemberLists[i].FamilyPID;
                        _self.FamilyMember.Relationship = familyMemberLists[i].Relationship;
                        _self.FamilyMember.Birthday = familyMemberLists[i].Birthday;
                        _self.FamilyMember.IsDefault = familyMemberLists[i].IsDefault;
                        _self.FamilyMember.IsSelected = _self.SelectedFamilyMemberId === familyMemberLists[i].Id ? true : false;
                        _self.FamilyMember.FamilyName = familyMemberLists[i].FamilyName;
                        _self.FamilyMember.FamilyMobile = familyMemberLists[i].FamilyMobile;
                        _self.FamilyMember.FamilyAddress = familyMemberLists[i].FamilyAddress;
                        _self.FamilyMember.Gender = familyMemberLists[i].Gender;
                        _self.FamilyMember.IDCardNo = familyMemberLists[i].IDCardNo;
                        _self.FamilyMember.CreateTime = familyMemberLists[i].CreateTime;
                        _self.FamilyMember.UpdateTime = familyMemberLists[i].UpdateTime;
                        _self.FamilyMember.Remark = familyMemberLists[i].Remark;

                        _self.FamilyMember.UserInfoJson.Pid = familyMemberLists[i].Pid;
                        _self.FamilyMember.UserInfoJson.Name = familyMemberLists[i].FamilyName;
                        _self.FamilyMember.UserInfoJson.Mobile = familyMemberLists[i].FamilyMobile;
                        _self.FamilyMember.UserInfoJson.Sex = familyMemberLists[i].Gender;
                        _self.FamilyMember.UserInfoJson.CertNo = familyMemberLists[i].IDCardNo;
                        _self.FamilyMember.UserInfoJson.Birthday = familyMemberLists[i].Birthday;

                        if (familyMemberLists[i].IsSelected) {
                            _self.SelectedFamilyMemberId = familyMemberLists[i].Id;
                            _self.userInfoJson = _self.FamilyMember.UserInfoJson;
                        }

                        if (_self.currentUserMobile != "" && _self.FamilyMember.FamilyMobile == _self.currentUserMobile) {
                            _self.validateCurrentUserDisable = "validateCurrentUserDisable";
                        }
                    }

                    if (_self.currentUserMobile != "" && familyMemberLists[i].FamilyMobile == _self.currentUserMobile) {
                        _self.validateCurrentUserDisable = "validateCurrentUserDisable";
                    }
                }

                _self.validateDisable = '';
                if (_self.FamilyMember.FamilyMobile == "" || _self.validateCurrentUserDisable == "orderValidateDisable") {
                    _self.validateDisable = "orderValidateDisable";
                }

                if (_self.FamilyMember.FamilyName != "" &&
                    _self.FamilyMember.FamilyMobile != "" &&
                    _self.FamilyMember.ValidateCode != "" &&
                    _self.FamilyMember.IDCardNo != "") {
                    _self.isFamilyMemberAddDisable = "";
                } else {
                    _self.isFamilyMemberAddDisable = "familyMemberAddDisable";
                }

                if (_self.currentUserMobile != "" && _self.FamilyMember.FamilyMobile == _self.currentUserMobile) {
                    _self.validateCurrentUserDisable = "validateCurrentUserDisable";
                    _self.FamilyMember.ValidateCode = "......";
                    _self.validateDisable = "orderValidateDisable";
                } else {
                    _self.validateCurrentUserDisable = "";
                    _self.validateDisable = "";
                }
            },
            clickCancel: function () {
                var _self = this;
                _self.familyTitle = "新增就诊人";
                _self.showAdd = false;
                _self.isUpdateFamilyMember = "";
                _self.validateCurrentUserDisable = "";
                _self.FamilyMember = {
                    Age: null,
                    Birthday: null,
                    CreateTime: '',
                    FamilyAddress: '',
                    FamilyMobile: '',
                    FamilyName: '',
                    FamilyPID: '',
                    Gender: '',
                    IDCardNo: '',
                    Id: -1,
                    IsDefault: false,
                    IsSelected: false,
                    Pid: -1,
                    Relationship: '',
                    Remark: '',
                    UpdateTime: '',
                    ValidateCode: '',
                    UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                };
            },
            clickCancelUpdate: function () {
                var _self = this;
                _self.showAdd = false;
                _self.validateCurrentUserDisable = "";
                _self.FamilyMember = {
                    Age: null,
                    Birthday: null,
                    CreateTime: '',
                    FamilyAddress: '',
                    FamilyMobile: '',
                    FamilyName: '',
                    FamilyPID: '',
                    Gender: '',
                    IDCardNo: '',
                    Id: -1,
                    IsDefault: false,
                    IsSelected: false,
                    Pid: -1,
                    Relationship: '',
                    Remark: '',
                    UpdateTime: '',
                    ValidateCode: '',
                    UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                };
            },
            showCityItem: function () {
                var _self = this;

                _self.bcityVisible = true;

                _self.citylist = [];
                this.$http.get("/Order/GetCityList").then(function (res) {
                    if (res.body != null) {
                        for (var i = 0; i < res.body.length; i++) {
                            _self.citylist.push(res.body[i]);
                        }

                        for (var i = 0; i < _self.citylist.length; i++) {
                            if (_self.citylist[i].id == _self.selectedCityId) {
                                _self.selectedCityId = _self.citylist[i].id;
                                _self.selectedCityName = _self.citylist[i].name;
                                _self.citylist[i].bcityActive = true;
                            } else {
                                _self.citylist[i].bcityActive = false;
                            }
                        }
                    } else {
                        _self.selectedCityId = "";
                        _self.selectedCityName = "请选择城市";
                    }

                    var showCity = document.getElementById("selectCityDiv");
                    showCity.style.display = "block";
                    $('.selectDepartment').hide();
                    $('.doctorTime_spotList').hide();
                    $('#dateWrap').hide();
                });
            },
            chooseCityItem: function ($event) {
                var _self = this;
                _self.selectedCityId = "";
                _self.selectedCityName = "";
                var selecteditem = $event.currentTarget.id;

                var selectcitylist = _self.citylist;
                for (var i = 0; i < selectcitylist.length; i++) {
                    if (selectcitylist[i].id == selecteditem) {
                        _self.selectedCityId = selectcitylist[i].id;
                        _self.selectedCityName = selectcitylist[i].name;
                        selectcitylist[i].bcityActive = true;
                    } else {
                        selectcitylist[i].bcityActive = false;
                    }
                }

                _self.selectedOrganizationId = "";
                _self.selectedOrganizationName = "请选择看诊地点";
                _self.selectedOrganizationAddress = "";
                _self.selectedOrganizationRemoteHospId = "";
                _self.IsRemote = "";
                _self.bcityVisible = false;
                $('.selectDepartment').hide();
                $('.doctorTime_spotList').hide();
                $('#dateWrap').hide();
                $('.selectCity').hide();
            },
            showOrganizationItem: function () {
                var _self = this;
                _self.organizationList = [];
                _self.bOrganizationVisible = true;

                if (_self.selectedCityName != "请选择城市") {
                    _self.$http.post("/Order/GetOrganizationList",
                        { cityID: _self.selectedCityId, keyword: "", page: 1, pageSize: 20 }).then(
                        function (res) {
                            if (res.status == 200) {
                                if (res.body.length > 0) {
                                    for (var i = 0; i < res.body.length; i++) {
                                        if (res.body[i].hospitalID == _self.selectedOrganizationId) {
                                            _self.selectedOrganizationId = res.body[i].hospitalID;
                                            _self.selectedOrganizationName = res.body[i].hospitalName;
                                            _self.selectedOrganizationAddress = res.body[i].hospitalAddress;
                                            _self.selectedOrganizationRemoteHospId = res.body[i].remote;
                                            _self.IsRemote = res.body[i].remote;

                                            res.body[i].borganizationActive = true;
                                        } else {
                                            res.body[i].borganizationActive = false;
                                        }
                                        _self.organizationList.push(res.body[i]);
                                    }
                                }
                                else {
                                    _self.selectedOrganizationId = "";
                                    _self.selectedOrganizationName = "请选择看诊地点";
                                    _self.selectedOrganizationAddress = "";
                                    _self.selectedOrganizationRemoteHospId = "";
                                    _self.IsRemote = "";
                                }
                            }
                        });
                } else {
                    _self.selectedOrganizationId = "";
                    _self.selectedOrganizationName = "请选择看诊地点";
                    _self.selectedOrganizationAddress = "";
                    _self.selectedOrganizationRemoteHospId = "";
                    _self.IsRemote = "";
                }

                $('.selectDepartment').show();
                $('.doctorTime_spotList').hide();
                $('.selectCity').hide();
                $('#dateWrap').hide();
            },
            chooseOrganizationItem: function ($event) {
                var _self = this;
                _self.selectedOrganizationId = "";
                _self.selectedOrganizationName = "";
                _self.selectedOrganizationAddress = "";
                _self.selectedOrganizationRemoteHospId = "";
                _self.IsRemote = "";
                var selecteditem = $event.currentTarget.id;

                var selectorganizationList = _self.organizationList;
                for (var i = 0; i < selectorganizationList.length; i++) {
                    if (selectorganizationList[i].hospitalID == selecteditem) {
                        _self.selectedOrganizationId = selectorganizationList[i].hospitalID;
                        _self.selectedOrganizationName = selectorganizationList[i].hospitalName;
                        _self.selectedOrganizationAddress = selectorganizationList[i].hospitalAddress;
                        _self.selectedOrganizationRemoteHospId = selectorganizationList[i].remote;
                        _self.IsRemote = selectorganizationList[i].remote;

                        selectorganizationList[i].borganizationActive = true;
                    } else {
                        selectorganizationList[i].borganizationActive = false;
                    }
                }

                if (_self.HospitalID != _self.selectedOrganizationId) {
                    _self.RegistrationFeeText = _self.RemoteRegistrationFee;
                } else if (_self.HospitalID == _self.selectedOrganizationId) {
                    _self.RegistrationFeeText = _self.RegistrationFee;
                } else {
                    _self.RegistrationFeeText = "";
                }

                _self.bOrganizationVisible = false;
                $('.selectDepartment').hide();
                $('.doctorTime_spotList').hide();
                $('#dateWrap').hide();
                $('.selectCity').hide();
            },
            showDoctorTimeItem: function () {
                var _self = this;
                $('.selectDepartment').hide();
                $('.selectCity').hide();
                $('#dateWrap').hide();
                var selectedtime = _self.inquiryDate;
                _self.bDoctorTimeVisible = true;
                if (selectedtime != "请选择日期") {
                    var doctorid = window.location.search.split('=')[1];

                    _self.selecteddoctorTime = _self.selecteddoctorTime != "请选择时间段" ? _self.selecteddoctorTime : "请选择时间段";
                    _self.doctorTimeList = [];

                    _self.morningTimeList = [];
                    _self.afternoonTimeList = [];
                    _self.eveningTimeList = [];

                    _self.morningspotshow = false;
                    _self.afternoonspotshow = false;
                    _self.eveningspotshow = false;

                    selectedtime = selectedtime.split(' ')[0];
                    _self.selecteddoctorDate = _self.inquiryDate;
                    _self.$http.post("/Order/GetDoctorSchedulingList",
                        { id: doctorid, startime: selectedtime }).then(
                        function (res) {
                            if (res.status == 200) {
                                for (var i = 0; i < res.body.length; i++) {
                                    var dataitem = res.body[i];
                                    _self.ClinicID = dataitem.ClinicID;
                                    _self.ClinicinfoID = dataitem.ClinicinfoID;
                                    _self.HospitalID = dataitem.HospitalID;

                                    for (var i = 0; i < dataitem.subdate.length; i++) {
                                        if (dataitem.subdate[i].TimeTarget == "AM") {
                                            _self.morningTime = { TimeTarget: '', Time: '', bmorningA_click: false, bmorningA_noClickActive: true };

                                            if (_self.selecteddoctorTime == dataitem.subdate[i].Time) {
                                                _self.morningTime.bmorningA_click = true;
                                            } else {
                                                _self.morningTime.bmorningA_click = false;
                                            }
                                            _self.morningTime.TimeTarget = dataitem.subdate[i].TimeTarget;
                                            _self.morningTime.Time = dataitem.subdate[i].Time;
                                            _self.morningTime.bmorningA_noClickActive = dataitem.subdate[i].NoBooking;

                                            _self.morningTimeList.push(_self.morningTime);
                                            _self.morningspotshow = true;
                                        } else if (dataitem.subdate[i].TimeTarget == "PM") {
                                            _self.afternoonTime = { TimeTarget: '', Time: '', bafternoonA_click: false, bafternoonA_noClickActive: true };

                                            if (_self.selecteddoctorTime == dataitem.subdate[i].Time) {
                                                _self.afternoonTime.bafternoonA_click = true;
                                            } else {
                                                _self.afternoonTime.bafternoonA_click = false;
                                            }

                                            _self.afternoonTime.TimeTarget = dataitem.subdate[i].TimeTarget;
                                            _self.afternoonTime.Time = dataitem.subdate[i].Time;
                                            _self.afternoonTime.bafternoonA_noClickActive = dataitem.subdate[i].NoBooking;

                                            _self.afternoonTimeList.push(_self.afternoonTime);
                                            _self.afternoonspotshow = true;
                                        } else if (dataitem.subdate[i].TimeTarget == "NM") {
                                            _self.eveningTime = { TimeTarget: '', Time: '', beveningA_click: false, beveningA_noClickActive: true };

                                            if (_self.selecteddoctorTime == dataitem.subdate[i].Time) {
                                                _self.eveningTime.beveningA_click = true;
                                            } else {
                                                _self.eveningTime.beveningA_click = false;
                                            }

                                            _self.eveningTime.TimeTarget = dataitem.subdate[i].TimeTarget;
                                            _self.eveningTime.Time = dataitem.subdate[i].Time;
                                            _self.eveningTime.beveningA_noClickActive = dataitem.subdate[i].NoBooking;

                                            _self.eveningTimeList.push(_self.eveningTime);
                                            _self.eveningspotshow = true;
                                        }
                                    }
                                }

                                _self.$http.post("/Order/GetClinicCategory",
                                    { id: _self.ClinicinfoID }).then(
                                    function (res) {
                                        if (res.status == 200) {
                                            _self.RegistrationFee = res.body.RegistrationFee;
                                            _self.RemoteRegistrationFee = res.body.RemoteRegistrationFee;
                                            if (_self.HospitalID != _self.selectedOrganizationId) {
                                                _self.RegistrationFeeText = _self.RemoteRegistrationFee;
                                            } else if (_self.HospitalID == _self.selectedOrganizationId) {
                                                _self.RegistrationFeeText = _self.RegistrationFee;
                                            } else {
                                                _self.RegistrationFeeText = "";
                                            }
                                        }
                                    });
                            }
                            var showDoctorTime = document.getElementById("doctorTime_spotListDiv");
                            showDoctorTime.style.display = "block";
                        });
                }
            },
            chooseDoctorTimeItem: function ($event) {
                var _self = this;
                _self.selecteddoctorTime = "请选择时间段";
                _self.selecteddoctorDate = _self.inquiryDate;
                var selecteditemTimeTarget = $event.currentTarget.id;
                var selecteditemTime = $event.currentTarget.text;
                var morningtimelist = _self.morningTimeList;
                var afternoontimelist = _self.afternoonTimeList;
                var eveningtimelist = _self.eveningTimeList;

                var classarr = $event.currentTarget.className.split('_');
                var canbeclick = classarr.indexOf('noClick');
                if (canbeclick == -1) {
                    if (selecteditemTime != "") {
                        _self.selecteddoctorTime = selecteditemTime;
                    }

                    if (selecteditemTimeTarget == "AM") {
                        if (morningtimelist.length > 0) {
                            for (var i = 0; i < morningtimelist.length; i++) {
                                if (morningtimelist[i].Time == selecteditemTime) {
                                    morningtimelist[i].bmorningA_click = true;
                                } else {
                                    morningtimelist[i].bmorningA_click = false;
                                }
                            }
                        }
                        if (afternoontimelist.length > 0) {
                            for (var i = 0; i < afternoontimelist.length; i++) {
                                afternoontimelist[i].bafternoonA_click = false;
                            }
                        }
                        if (eveningtimelist.length > 0) {
                            for (var i = 0; i < eveningtimelist.length; i++) {
                                eveningtimelist[i].beveningA_click = false;
                            }
                        }
                    } else if (selecteditemTimeTarget == "PM") {
                        if (morningtimelist.length > 0) {
                            for (var i = 0; i < morningtimelist.length; i++) {
                                morningtimelist[i].bmorningA_click = false;
                            }
                        }
                        if (afternoontimelist.length > 0) {
                            for (var i = 0; i < afternoontimelist.length; i++) {
                                if (afternoontimelist[i].Time == selecteditemTime) {
                                    afternoontimelist[i].bafternoonA_click = true;
                                } else {
                                    afternoontimelist[i].bafternoonA_click = false;
                                }
                            }
                        }
                        if (eveningtimelist.length > 0) {
                            for (var i = 0; i < eveningtimelist.length; i++) {
                                eveningtimelist[i].beveningA_click = false;
                            }
                        }
                    } else if (selecteditemTimeTarget == "NM") {
                        if (morningtimelist.length > 0) {
                            for (var i = 0; i < morningtimelist.length; i++) {
                                morningtimelist[i].bmorningA_click = false;
                            }
                        }
                        if (afternoontimelist.length > 0) {
                            for (var i = 0; i < afternoontimelist.length; i++) {
                                afternoontimelist[i].bafternoonA_click = false;
                            }
                        }
                        if (eveningtimelist.length > 0) {
                            for (var i = 0; i < eveningtimelist.length; i++) {
                                if (eveningtimelist[i].Time == selecteditemTime) {
                                    eveningtimelist[i].beveningA_click = true;
                                } else {
                                    eveningtimelist[i].beveningA_click = false;
                                }
                            }
                        }
                    }

                    _self.bDoctorTimeVisible = false;
                }
            },
            addPic: function (e) {
                e.preventDefault();
                $('input[type=file]').trigger('click');
                return false;
            },
            onFileChange: function (e) {
                var files = e.target.files || e.dataTransfer.files;
                if (!files.length) return;
                this.createImage(files);
            },
            createImage: function (file) {
                if (typeof FileReader === 'undefined') {
                    alert('您的浏览器不支持图片上传，请升级您的浏览器');
                    return false;
                }
                var image = new Image();
                var _self = this;
                var leng = file.length;
                for (var i = 0; i < leng; i++) {
                    var reader = new FileReader();
                    reader.readAsDataURL(file[i]);
                    reader.onload = function (e) {
                        var objimages = e.target.result;
                        _self.$http.post("/Order/UploadImage",
                            { data: objimages }).then(
                            function (res) {
                                var imageitem = { src: '' };
                                imageitem.src = res.body[0];
                                _self.images.push(res.body[0]);
                                _self.saveimages.push(res.body[0]);
                            });
                    };
                }
            },
            delImage: function (index) {
                for (var i = 0; i < this.images.length; i++) {
                    if (this.images[i] == index) {
                        this.images.splice(i, 1);
                        break;
                    }
                }
            },
            setOrderSuccess: function () {
                //预约成功弹窗赋值
                this.orderSuccess.expertName = this.doctorInfo.Name; //医生名字
                this.selecteddoctorDate = this.inquiryDate;
                if (this.selecteddoctorDate) {
                    var dateArr = this.selecteddoctorDate.split(' ')[0].split('-');
                    this.orderSuccess.date = dateArr[0] + '年' + dateArr[1] + '月' + dateArr[2] + '日' + this.selecteddoctorTime; //就诊时间
                }

                this.orderSuccess.hospital = this.selectedOrganizationName; //就诊医院
                this.orderSuccess.address = this.selectedOrganizationAddress; //就诊地址
                this.orderSuccess.fee = this.RegistrationFeeText; //就诊费用
                this.orderSuccess.doctorId = this.doctorInfo.Id;
            },
            ResvIntentionAdd: function () {
                var _self = this;
                this.selecteddoctorDate = this.inquiryDate;
                var type = 0;
                var hospId = _self.selectedOrganizationId;
                var remoteHospId = _self.HospitalID;
                var depId = _self.ClinicID;
                var depTypeId = _self.ClinicinfoID;
                var doctorId = _self.doctorInfo.Id;
                var timePeriod = _self.selecteddoctorTime;

                var resvDate = _self.selecteddoctorDate.split(' ')[0];
                var description = _self.description;
                var pictures = _self.saveimages;
                var userIP = "";
                var platform = "Web";
                var OpenId = "";

                if (hospId == "" ||
                    remoteHospId == "" ||
                    depId == "" ||
                    depTypeId == "" ||
                    doctorId == "" ||
                    timePeriod == "" ||
                    resvDate == "") {
                    return false;
                }

                this.setOrderSuccess();

                if (_self.pid == 0) {
                    if (_self.FamilyMember.FamilyName == null || _self.FamilyMember.FamilyName == "") {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "请输入就诊人信息" });
                        return false;
                    }

                    if (_self.FamilyMember.IDCardNo == null || _self.FamilyMember.IDCardNo == "") {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "请输入就诊人卡号" });
                        return false;
                    }

                    var familyMemberNoAndValidationCodeKey = _self.FamilyMember.FamilyMobile + $(".validateCode").val();
                    if (_self.FamilyMemberNoAndValidationCodeKey != familyMemberNoAndValidationCodeKey) {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "就诊人手机号与验证码不匹配" });
                        return false;
                    }
                    _self.$http.post("/Order/ResvIntentionAdd",
                        {
                            pid: 0, type: type, hospId: hospId, remoteHospId: remoteHospId, depId: depId, depTypeId: depTypeId, doctorId: doctorId, timePeriod: timePeriod, resvDate: resvDate,
                            description: description, pictures: pictures, userIP: userIP, platform: platform, OpenId: OpenId,
                            userInfoJson: JSON.stringify({
                                'Name': _self.FamilyMember.FamilyName,
                                'Mobile': _self.FamilyMember.FamilyMobile,
                                'Sex': "NoSex",
                                'CertNo': _self.FamilyMember.IDCardNo,
                                'Birthday': "NoBirthday"
                            }), idCardNo: _self.FamilyMember.IDCardNo
                        }).then(
                        function (res) {
                            if (res.status == 200 && res.body.Data != null) {
                                _self.orderSuccess.doctorId = _self.doctorInfo.Id;
                                _self.orderSuccess.date = _self.selecteddoctorDate.split(' ')[0] + " " + _self.selecteddoctorTime;
                                _self.orderSuccess.expertName = _self.doctorInfo.Name;
                                _self.orderSuccess.hospital = _self.selectedOrganizationName;
                                _self.orderSuccess.address = _self.selectedOrganizationAddress;
                                _self.orderSuccess.fee = _self.RegistrationFeeText;

                                _self.orderSuccess.show = true;
                            } else {
                                _self.orderSuccess.doctorId = "";
                                _self.orderSuccess.date = "";
                                _self.orderSuccess.expertName = "";
                                _self.orderSuccess.hospital = "";
                                _self.orderSuccess.address = "";
                                _self.orderSuccess.fee = "";

                                _self.orderSuccess.show = false;
                                dialogTip({ url: '/styles/image/icon/no.png', text: res.body.Message });
                            }
                        });
                } else {
                    if (_self.SelectedUserInfoJson.Name == null || _self.SelectedUserInfoJson.Name == "") {
                        _self.orderSuccess.show = false;
                        dialogTip({ url: '/styles/image/icon/no.png', text: "请选择就诊人" });
                        return false;
                    }
                    _self.$http.post("/Order/ResvIntentionAdd",
                        {
                            pid: _self.SelectedUserInfoJson.Pid, type: type, hospId: hospId, remoteHospId: remoteHospId, depId: depId, depTypeId: depTypeId, doctorId: doctorId, timePeriod: timePeriod, resvDate: resvDate,
                            description: description, pictures: pictures, userIP: userIP, platform: platform, OpenId: OpenId,
                            userInfoJson: JSON.stringify({
                                'Name': _self.SelectedUserInfoJson.Name,
                                'Mobile': _self.SelectedUserInfoJson.Mobile,
                                'Sex': "NoSex",
                                'CertNo': _self.SelectedUserInfoJson.CertNo,
                                'Birthday': "NoBirthday"
                            }), idCardNo: _self.SelectedUserInfoJson.CertNo
                        }).then(
                        function (res) {
                            if (res.status == 200 && res.body.Data != null) {
                                _self.orderSuccess.doctorId = _self.doctorInfo.Id;
                                _self.orderSuccess.date = _self.selecteddoctorDate.split(' ')[0] + " " + _self.selecteddoctorTime;
                                _self.orderSuccess.expertName = _self.doctorInfo.Name;
                                _self.orderSuccess.hospital = _self.selectedOrganizationName;
                                _self.orderSuccess.address = _self.selectedOrganizationAddress;
                                _self.orderSuccess.fee = _self.RegistrationFeeText;

                                _self.orderSuccess.show = true;
                            } else {
                                _self.orderSuccess.doctorId = "";
                                _self.orderSuccess.date = "";
                                _self.orderSuccess.expertName = "";
                                _self.orderSuccess.hospital = "";
                                _self.orderSuccess.address = "";
                                _self.orderSuccess.fee = "";

                                _self.orderSuccess.show = false;
                                dialogTip({ url: '/styles/image/icon/no.png', text: res.body.Message });
                            }
                        });
                }
            },
            openIntroduce: function () {
                this.allGoodText = true;
            },
            closeIntroduce: function () {
                this.allGoodText = false;
            }
        },
        mounted: function () {
            //this.getDate();
            showHtml();
            createCode();
            var tipBox = document.getElementById("tipBox");
            tipBox.style.display = "none";
            var _self = this;
            //设置导航栏样式
            document.getElementById("Home").className = "invalid-nav";
            document.getElementById("OrderExpert").className = "valid-nav";
            document.getElementById("DistinctMedical").className = "invalid-nav";
            document.getElementById("MedicalWiki").className = "invalid-nav";
            document.getElementById("News").className = "invalid-nav";
            document.getElementById("AboutUs").className = "invalid-nav";

            var doctorid = window.location.search.split('=')[1];
            _self.doctorInfo = {
                Id: "",
                Name: '',
                Image: '',
                DeptName: '',
                DepName2: '',
                DeptID: '',
                TitleName: '',
                OrgName: '',
                AffiliatedHospital: '',
                SkillIn: '',
                DocInfo: '',
                SkillInText: '',
                DocInfoText: ''
            };
            _self.$http.post("/Order/GetDoctorInfo",
                { id: doctorid }).then(
                function (res) {
                    if (res.status == 200) {
                        _self.doctorInfo.Id = res.body.Id;
                        _self.doctorInfo.Image = res.body.Image;
                        _self.doctorInfo.Name = res.body.Name;
                        _self.doctorInfo.DeptName = res.body.DeptName;
                        _self.doctorInfo.DepName2 = res.body.DepName2;
                        _self.doctorInfo.DeptID = res.body.DeptID;
                        _self.doctorInfo.TitleName = res.body.TitleName;
                        _self.doctorInfo.OrgId = res.body.OrgId;
                        _self.doctorInfo.OrgName = res.body.OrgName;
                        _self.doctorInfo.AffiliatedHospital = res.body.AffiliatedHospital;
                        _self.doctorInfo.SkillIn = res.body.SkillIn;
                        _self.doctorInfo.DocInfo = res.body.DocInfo;
                        _self.doctorInfo.SkillInText = res.body.SkillInText;
                        _self.doctorInfo.DocInfoText = res.body.DocInfoText;
                        _self.Name = res.body.Name;
                        _self.OrgName = res.body.OrgName;
                        //显示省略号
                        overflowEllipsis(_self);
                    }
                });

            _self.pid = 0;
            _self.$http.post("/Order/GetLoginUser",
                { pid: _self.pid }).then(
                function (res) {
                    _self.pid = res.body.pid;
                    _self.currentUserMobile = res.body.mobile;
                    if (_self.pid == 0) {
                        _self.showAdd = true;
                        _self.isGuset = false;
                    }
                });

            _self.doctorTimeList = [];
            _self.familyMemberList = [];
            this.$http.post("/Order/GetFamilyMemberList",
                { pid: _self.pid }).then(function (res) {
                for (var i = 0; i < res.body.length; i++) {
                    _self.FamilyMember = {
                        Age: null,
                        Birthday: null,
                        CreateTime: '',
                        FamilyAddress: '',
                        FamilyMobile: '',
                        FamilyName: '',
                        FamilyPID: '',
                        Gender: '',
                        IDCardNo: '',
                        Id: -1,
                        IsDefault: false,
                        IsSelected: false,
                        Pid: -1,
                        Relationship: '',
                        Remark: '',
                        UpdateTime: '',
                        ValidateCode: '',
                        UserInfoJson: { Pid: -1, Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                    };
                    _self.FamilyMember.Id = res.body[i].Id;
                    _self.FamilyMember.Age = res.body[i].Age;
                    _self.FamilyMember.Pid = res.body[i].Pid;
                    _self.FamilyMember.FamilyPID = res.body[i].FamilyPID;
                    _self.FamilyMember.Relationship = res.body[i].Relationship;
                    _self.FamilyMember.Birthday = res.body[i].Birthday;
                    _self.FamilyMember.IsDefault = res.body[i].IsDefault;
                    _self.FamilyMember.IsSelected = res.body[i].IsDefault;
                    _self.FamilyMember.FamilyName = res.body[i].FamilyName;
                    _self.FamilyMember.FamilyMobile = res.body[i].FamilyMobile;
                    _self.FamilyMember.FamilyAddress = res.body[i].FamilyAddress;
                    _self.FamilyMember.Gender = res.body[i].Gender;
                    _self.FamilyMember.IDCardNo = res.body[i].IDCardNo;
                    _self.FamilyMember.CreateTime = res.body[i].CreateTime;
                    _self.FamilyMember.UpdateTime = res.body[i].UpdateTime;
                    _self.FamilyMember.Remark = res.body[i].Remark;

                    _self.FamilyMember.UserInfoJson.Pid = res.body[i].Pid;
                    _self.FamilyMember.UserInfoJson.Name = res.body[i].FamilyName;
                    _self.FamilyMember.UserInfoJson.Mobile = res.body[i].FamilyMobile;
                    _self.FamilyMember.UserInfoJson.Sex = res.body[i].Gender;
                    _self.FamilyMember.UserInfoJson.CertNo = res.body[i].IDCardNo;
                    _self.FamilyMember.UserInfoJson.Birthday = res.body[i].Birthday;

                    if (res.body[i].IsSelected) {
                        _self.SelectedFamilyMemberId = res.body[i].Id;
                        _self.SelectedUserInfoJson = _self.FamilyMember.UserInfoJson;
                        _self.userInfoJson = _self.FamilyMember.UserInfoJson;
                    }

                    _self.familyMemberList.push(_self.FamilyMember);
                }
                _self.FamilyMember = {
                    Age: null,
                    Birthday: null,
                    CreateTime: '',
                    FamilyAddress: '',
                    FamilyMobile: '',
                    FamilyName: '',
                    FamilyPID: '',
                    Gender: '',
                    IDCardNo: '',
                    Id: -1,
                    IsDefault: false,
                    IsSelected: false,
                    Pid: -1,
                    Relationship: '',
                    Remark: '',
                    UpdateTime: '',
                    ValidateCode: '',
                    UserInfoJson: { Name: "", Mobile: "", Sex: "", CertNo: "", Birthday: "" }
                };
            });
            $('#dateWrap').hide();
        }
    });
})(Vue)